package com.game.ThauanFramework;

import java.security.KeyPair;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.inputmethodservice.KeyboardView;
import android.util.Log;

import com.thauanLopes.smagasmaga.R;

public class BitmapStorage {
	
	private final String TAG = "Bitmap Storage";
	
	public HashMap<Integer, Bitmap> imgs;

	private static BitmapStorage instance;
	
	public static BitmapStorage getInstance()
	{
		if(instance == null)
		{
			instance = new BitmapStorage();
		}
		
		return instance;
	}
	private BitmapStorage()
	{	
		
		this.imgs = new HashMap<Integer, Bitmap>();
		
		CreateBitmap(R.drawable.spritesheet_bacteria_normal);
		CreateBitmap(R.drawable.spritesheet_bacteria_normal2);
		CreateBitmap(R.drawable.spritesheet_bacteria_normal3);
		CreateBitmap(R.drawable.spritesheet_bacteria_normal4);
		CreateBitmap(R.drawable.spritesheet_bacteria_normal5);
		CreateBitmap(R.drawable.helmet);
		CreateBitmap(R.drawable.static_background);
		CreateBitmap(R.drawable.spritesheet_olhopego);
		CreateBitmap(R.drawable.bacteria_change_mode);
		CreateBitmap(R.drawable.bacteria_armadilha);
		CreateBitmap(R.drawable.bacteria_espacial);
		CreateBitmap(R.drawable.bacteria_time);
		
		// Monsters
		CreateBitmap(R.drawable.monstro_shield);
		CreateBitmap(R.drawable.monstro_normal);
		CreateBitmap(R.drawable.monstro_qte);
		CreateBitmap(R.drawable.monstro_background);
		CreateBitmap(R.drawable.monstro_efeito_pos_morte);
		
		CreateBitmap(R.drawable.shield_left);
		CreateBitmap(R.drawable.shield_right);
		CreateBitmap(R.drawable.shield_norte);
		CreateBitmap(R.drawable.shield_sul);

	}
	
	public void CreateBitmap(int source)
	{
		try{
			Bitmap tmpBitmap = BitmapFactory.decodeResource(Util.getResources(), source);
			this.imgs.put(source, tmpBitmap);
		}
		catch (Exception e)
		{
			Util.Show("Erro ao criar Bitmap");
		}
	}
	public Bitmap getBitmap(int source)
	{
		return this.imgs.get(source);
	}
}
